package com.pg.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.ycl.EipInsulator;
import com.pg.mapper.EipInsulatorMapper;
import com.pg.service.EipInsulatorService;
import com.pg.utils.Jpg2Base64Util;
import com.pg.utils.UploadFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 盆式绝缘子/支持绝缘子和局放值 服务实现类
 * </p>
 *
 * @Author likl
 * @since 2020-10-26
 */
@Service
@DS("proxyDs")
@Primary
public class EipInsulatorServiceImpl extends ServiceImpl<EipInsulatorMapper, EipInsulator> implements EipInsulatorService {

    @Autowired
    private EipInsulatorMapper eipInsulatorMapper;

    @Override
    public void saveOne(EipInsulator insulator)  {
        if (insulator.getCheckResult() != null) {
            String filePath = "/root/" + insulator.getCheckResult();
            insulator.setCheckResultObj(UploadFileUtils.uploadFiles(Jpg2Base64Util.Jpg2Base64(filePath)));
            eipInsulatorMapper.insert(insulator);
        } else {
            insulator.setCheckResultObj(null);
            eipInsulatorMapper.insert(insulator);
        }
    }
}
